package com.neuedu.hisadmin.service.impl;

//import com.neuedu.hisadmin.entity.Register;
//import com.neuedu.hisadmin.mapper.RegisterMapper;
//import com.neuedu.hisadmin.service.IRegisterService;
//import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
//import org.springframework.stereotype.Service;
//
///**
// * <p>
// *  服务实现类
// * </p>
// *
// * @author jaun
// * @since 2025-07-05
// */
//@Service
//public class RegisterServiceImpl extends ServiceImpl<RegisterMapper, Register> implements IRegisterService {
//
//}


//package com.neuedu.hisboot.service.impl;
//
//import com.neuedu.hisboot.entity.Register;
//import com.neuedu.hisboot.mapper.RegisterMapper;
//import com.neuedu.hisboot.service.IRegisterService;
//import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
//import org.springframework.stereotype.Service;
//
///**
// * <p>
// *  服务实现类
// * </p>
// *
// * @author jaun
// * @since 2025-07-04
// */
//@Service
//public class RegisterServiceImpl extends ServiceImpl<RegisterMapper, Register> implements IRegisterService {
//
//}
//package com.neuedu.hisboot.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.neuedu.hisadmin.dto.RegisterDTO;
import com.neuedu.hisadmin.entity.Register;
import com.neuedu.hisadmin.mapper.RegisterMapper;
import com.neuedu.hisadmin.service.IRegisterService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RegisterServiceImpl extends ServiceImpl<RegisterMapper, Register> implements IRegisterService {


    @Override
    public List<Register> queryRefundableRegisters(RegisterDTO dto) {
        return baseMapper.selectRefundableRegisters(dto.getKeyword());
    }


    @Override
    public boolean doRefund(Integer registerId) {
        // 调用 Mapper 的更新方法，执行退号逻辑
        int affectedRows = baseMapper.updateRegisterState(registerId);
        // 根据受影响行数判断是否退号成功
        return affectedRows > 0;
    }
}